package com.nowc.week.w110;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

public class b {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        int t =  Integer.parseInt(br.readLine());
        while (t-- > 0) {
            solve();
        }
        out.flush();
        out.close();
        br.close();
    }

    static void solve() throws IOException {
         String[] in = br.readLine().split(" ");
         int n = Integer.parseInt(in[0]);
         in = br.readLine().split(" ");
         int[] a = new int[n];
         for (int i = 0; i < n; i++) {
             a[i] = Integer.parseInt(in[i]);
         }
         Arrays.sort(a);
         long ans = 0;
         if (n <= 2) {
             ans = a[0] + a[1];
         } else {
             ans += a[n - 1] * 2L;
             for (int i = n - 2, pre = 0; i >= 0; i -= 2) {
                 ans += a[i] + pre;
                 pre = a[i];
             }
             for (int i = n - 3, pre = 0; i >= 0; i -= 2) {
                 ans += a[i] + pre;
                 pre = a[i];
             }
         }
         out.println(ans);
    }
}
